package com.wman;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("say")
public class HelloController {

    @Value("${wman}")
    private String wman;

    @Autowired
    private GirlProperties mGirlProperties;

    //http://localhost:8080/wman/say/hi/2222
    @RequestMapping(value = {"/hello/{id}", "/hi/{id}"}, method = RequestMethod.GET)
    public String say(@PathVariable("id") Integer id) {
        return wman + " : " + mGirlProperties.toString() + "\n" +
                "id:" + id;
    }

    //http://localhost:8080/wman/say/id?id=1212
    //@RequestMapping(value = "/id", method = RequestMethod.GET)
    @GetMapping(value = "/id")
    public String sayId(@RequestParam(value = "id", required = false, defaultValue = "0") Integer ID) {
        return "id:" + ID;
    }
}
